package simonby.top.annualring.infrastructure.repository;

import simonby.top.annualring.domain.model.FamilyTree;
import simonby.top.annualring.domain.repository.FamilyTreeRepository;
import org.springframework.stereotype.Repository;
import simonby.top.annualring.infrastructure.dao.FamilyTreeDao;

import java.util.List;
import java.util.Optional;

/**
 * 家族树仓储的实现
 */
@Repository
public class FamilyTreeRepositoryImpl implements FamilyTreeRepository {
    private final FamilyTreeDao familyTreeDao;

    public FamilyTreeRepositoryImpl(FamilyTreeDao familyTreeDao) {
        this.familyTreeDao = familyTreeDao;
    }

    @Override
    public FamilyTree save(FamilyTree familyTree) {
        return familyTreeDao.save(familyTree);
    }

    @Override
    public Optional<FamilyTree> findById(Long id) {
        return familyTreeDao.findById(id);
    }

    @Override
    public List<FamilyTree> findByCreatorId(Long creatorId) {
        return familyTreeDao.findByCreatorId(creatorId);
    }

    @Override
    public List<FamilyTree> findAll() {
        return familyTreeDao.findAll();
    }

    @Override
    public void deleteById(Long id) {
        familyTreeDao.deleteById(id);
    }

    @Override
    public Optional<FamilyTree> findByName(String name) {
        return familyTreeDao.findByName(name);
    }
}